package engine.render.buffer;

import engine.render.GLManager;
import engine.render.type.RasterText;
import engine.res.Color;
import java.util.Iterator;
import java.util.LinkedList;

public class TextBuffer 
{
    
    private LinkedList<RasterText> rasters;
    
    public TextBuffer() 
    {
        rasters = new LinkedList<RasterText>();
    }
    
    public void text(int xpos, int ypos, String text) 
    {
        RasterText raster = new RasterText(xpos, ypos, text);
        rasterText(raster);
    }
    
    public void text(int xpos, int ypos, String text, Color modifier) 
    {
        RasterText raster = new RasterText(xpos, ypos, text, modifier);
        rasterText(raster);
    }
    
    public void rasterText(RasterText raster) 
    {
        rasters.addLast(raster);
    }
    
    public void renderRasters(GLManager glManager) 
    {
        Iterator iterRasters = rasters.iterator();
        while (iterRasters.hasNext()) 
        {
            ((RasterText) iterRasters.next()).render(glManager);
        }
    }
    
    public void clearRasters() 
    {
        rasters.clear();
    }
    
}
